package chai.ningning.tcp;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketAddress;

public class FirstServer {

    public static void main(String[] args) throws IOException {

        //指定主机地址，端口号
        final String host = "1.0.0.58";
        final int port = 5555;

        //创建ServerSocket对象（用来提供服务）3
        ServerSocket serverSocket = new ServerSocket();

        //为 ServerSocket 绑定 IP地址 和端口
        SocketAddress endpoint = new InetSocketAddress(host,port);
        serverSocket.bind(endpoint);

        //侦听来自客户端的连接
        Socket client = serverSocket.accept();
        System.out.println(client);
        //关闭ServerSocket
        serverSocket.close();
    }
}
